package com.cx.service.impl;

import com.cx.dto.AllHotel;
import com.cx.dto.ElasticSearchDto;
import com.cx.dto.HotelInfo;
import com.cx.dto.RecentHotel;
import com.cx.mapper.HotelMapper;
import com.cx.service.HotelMapperService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HotelMapperServiceImpl implements HotelMapperService {
    public static int count;
    @Autowired
    HotelMapper hotelMapper;
    @Override
    public List<HotelInfo> findHotelInfoBYHotelName(String hotelName) {
        return hotelMapper.findHotelInfoBYHotelName(hotelName);
    }

    @Override
    public List<AllHotel> findHotelByCondition(String[] locate, String[] brand, String[] mininumCharge, String[] service,Integer pageNum,boolean priceFlag,boolean scoreFlag) {
//         List<AllHotel> countList = hotelMapper.findHotelByCondition(locate,brand,mininumCharge,service);
        //这个是用来统计一共多少条数据符合要求
         PageHelper.startPage(pageNum,5);
         List<AllHotel> allHotels = hotelMapper.findHotelByCondition(locate,brand,mininumCharge,service,priceFlag,scoreFlag);
        return allHotels;
    }
    //用来返回符合条件的数据条数
    @Override
    public int count(String[] locate, String[] brand, String[] mininumCharge, String[] service,Integer pageNum,boolean priceFlag,boolean scoreFlag){
        List<AllHotel> allHotels = hotelMapper.findHotelByCondition(locate,brand,mininumCharge,service,priceFlag,scoreFlag);
        return allHotels.size();
    }

    @Override
    public List<RecentHotel> findRecentHotelByCity(String cityName) {
        return hotelMapper.findRecentHotelByCity(cityName);
    }

    @Override
    public List<AllHotel> findHotelByKeyWords(String keyWords) {
        return hotelMapper.findHotelByKeyWords(keyWords);
    }

    @Override
    public List<ElasticSearchDto> findAllHotel() {
        return hotelMapper.findAllHotel();
    }
}
